package com.hq.ims.platform.controller;

import com.hq.ims.data.annotation.UserOperationMonitor;
import com.hq.ims.data.entityenum.EnumBusinessTypeStatus;
import com.hq.ims.data.service.BaseBusiInfoService;
import com.hq.ims.data.utils.LocalConstant;
import com.hq.ims.data.vo.BusiInfoMapstruct;
import com.hq.ims.platform.busservice.PlatformBigDataService;
import com.hq.ims.platform.busservice.PlatformBusiInfoService;
import com.hq.mybatis.base.page.RequestPage;
import com.hq.mybatis.base.page.ReturnPage;
import com.hq.utils.vo.ReturnVo;
import com.hq.web.annotations.GetJsonValue;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author yinzhangxiao
 * @date 2024/10/25 17:06
 * @ClassName PlatformBigDataController
 **/
@Api(tags = "大数据采集")
@RestController
@RequestMapping(LocalConstant.SYS_TYPE_PLATFORM_URL_PREFIX + "/sys/bigdata")
public class PlatformBigDataController {
    @Resource
    private PlatformBusiInfoService platformBusiInfoService;
    @Resource
    private BaseBusiInfoService baseBusiInfoService;
    @Resource
    private PlatformBigDataService platformBigDataService;

    @ApiOperation(value = "大数据采集分页", consumes = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({})
    @PostMapping(value = "/getPage", consumes = MediaType.APPLICATION_JSON_VALUE)
    public ReturnVo<ReturnPage> getPage(
            @RequestBody RequestPage page,
            @RequestBody BusiInfoMapstruct.PageSearchVo searchVo
    ) {
        searchVo.setInfoType(EnumBusinessTypeStatus.BigData);
        baseBusiInfoService.getByPage(page,searchVo);
        return ReturnVo.buildSuccess(page.getReturnPage());
    }
    @ApiOperation(value = "新增经营信息", consumes = MediaType.APPLICATION_JSON_VALUE)
    @UserOperationMonitor
    @ApiImplicitParams({})
    @PostMapping(value = "/addData", consumes = MediaType.APPLICATION_JSON_VALUE)
    public ReturnVo<Boolean> addData(@RequestBody BusiInfoMapstruct.SaveVo vo) {
        platformBigDataService.addBusiInfo(vo);
        return ReturnVo.buildSuccess(true);
    }
    @ApiOperation(value = "编辑经营信息", consumes = MediaType.APPLICATION_JSON_VALUE)
    @UserOperationMonitor
    @ApiImplicitParams({})
    @PostMapping(value = "/updateData", consumes = MediaType.APPLICATION_JSON_VALUE)
    public ReturnVo<Boolean> updateData(@RequestBody BusiInfoMapstruct.SaveVo vo) {
        platformBigDataService.editBusiInfo(vo);
        return ReturnVo.buildSuccess(true);
    }

    @ApiOperation(value = "发布经营信息", consumes = MediaType.APPLICATION_JSON_VALUE)
    @UserOperationMonitor
    @ApiImplicitParams({})
    @PostMapping(value = "/publishData", consumes = MediaType.APPLICATION_JSON_VALUE)
    public ReturnVo<Boolean> publishData(@GetJsonValue(zh = "数据ID") String busiInfoId) {
        platformBigDataService.publishData(busiInfoId);
        return ReturnVo.buildSuccess(true);
    }

    @ApiOperation(value = "作废经营信息", consumes = MediaType.APPLICATION_JSON_VALUE)
    @UserOperationMonitor
    @ApiImplicitParams({})
    @PostMapping(value = "/obsoleteData", consumes = MediaType.APPLICATION_JSON_VALUE)
    public ReturnVo<Boolean> obsoleteData(@GetJsonValue(zh = "数据ID") String busiInfoId) {
        platformBigDataService.obsoleteData(busiInfoId);
        return ReturnVo.buildSuccess(true);
    }

    @ApiOperation(value = "获取经营信息", consumes = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({})
    @PostMapping(value = "/getData", consumes = MediaType.APPLICATION_JSON_VALUE)
    public ReturnVo<BusiInfoMapstruct.BusiInfoVo> getData(@GetJsonValue(zh = "数据ID") String busiInfoId) {
        return ReturnVo.buildSuccess(baseBusiInfoService.getDetailVo(busiInfoId));
    }

}
